<ol class="breadcrumb">
    <li><a href="#">点单服务</a></li>
    <li>商品管理</li>
</ol>

<div class="panel panel-default">
    <div class="panel-heading">
        <span class="glyphicon glyphicon-list"></span>
        <span class="panel-title">商品列表</span>
        <% if(session.permissionMap[4003]){ %>
        <a href="/cafe/goods/to/create" class="pull-right btn btn-success btn-sm" style="margin-top: -3px;">
            <span class="glyphicon glyphicon-plus"></span>
            <span>新增</span>
        </a>
        <% } %>
    </div>
    <div class="table-responsive">
        <table class="table table-striped table-hover">
            <thead>
            <tr>
                <th>商品编号</th>
                <th>商品名称</th>
                <th>商品类目</th>
                <th>商品备注</th>
                <th>商品价格</th>
                <th>商品图片</th>
                <th>操作</th>
            </tr>
            </thead>
            <tfoot>
            <tr>
                <td colspan="7">
                    <nav class="twbsPagination"></nav>
                </td>
            </tr>
            </tfoot>
            <tbody>
            <% goodses.forEach(function (element, index, array) { %>
            <tr>
                <td><%= element._id %></td>
                <td><%= element.name %></td>
                <td><%= element.category %></td>
                <td><%= element.note %></td>
                <td>￥<%= element.price_cn %></td>
                <td>
                    <img src="<%= element.pic_url %>?imageView2/2/w/50/interlace/0/q/50">
                </td>
                <td>
                    <% if(session.permissionMap[4005]){ %>
                    <a href="/cafe/goods/to/edit/<%= element._id %>" class="btn btn-primary btn-sm">编辑</a>
                    <% } %>
                    <% if(session.permissionMap[4004]){ %>
                    <a href="/cafe/goods/remove/<%= element._id %>" onclick="return confirm('你确定要删除这个商品吗？')"
                       class="btn btn-danger btn-sm">删除</a>
                    <% } %>
                </td>
            </tr>

            <% }); %>
            </tbody>
        </table>
    </div>
</div>

<script type="text/javascript">
    $(function () {
        //分页功能
        $('.twbsPagination').twbsPagination({
            totalPages: <%=pageCount%>,
            visiblePages: 10,
            href: '/cafe/goods/list?num={{number}}'
        });
    });
</script>